#include "enemy3.h"
#include"config.h"

Enemy3::Enemy3()
{
    //敌机资源加载
    m_enemy3.load(ENEMY3_PATH);

    //敌机位置
    m_X3=0;
    m_Y3=0;

    //敌机状态
    m_Free3=true;

    //敌机速度
    m_Speed3=ENEMY3_SPEED;
    m_Speed4=ENEMY4_SPEED;

    //敌机矩形框（碰撞检测）
    m_Rect3.setWidth(m_enemy3.width());
    m_Rect3.setHeight(m_enemy3.height());
    m_Rect3.moveTo(m_X3,m_Y3);
}

void Enemy3::updatePosition()
{
    //空闲状态敌机 不计算坐标
    if(m_Free3)
    {
        return;
    }

    if(HP==2)
    m_Y3+=m_Speed3;
    if(HP==1)
         m_Y3+=m_Speed4;
    m_Rect3.moveTo(m_X3,m_Y3);

    //如果超出屏幕 重置空闲状态
    if(m_Y3>=GAME_HEIGHT+m_Rect3.height())
    {
        m_Free3=true;
    }
}
